home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / midimod2.zip / MIDIMOD.H < prev    next >
Text File  |  1993-06-29  |  7KB  |  257 lines

  1. /*
  2.  * MIDIMOD.H - Amiga Module to MIDI file converter header
  3.  * (c)opyright Andrew Scott 1993
  4.  *
  5.  * Turbo C 2.0
  6.  *
  7.  * Author: Andrew Scott (Adrenalin Software)
  8.  *
  9.  * Date: 14/3/1993 ver 0.1
  10.  *       20/4/1993 ver 0.2
  11.  */
  12.  
  13. /* File buffer size.. increase for better performance */
  14. #define BUFFSIZE 512
  15.  
  16. /* Max line length in text files */
  17. #define MAXSTRING 128
  18.  
  19. /* MIDI instrument file */
  20. #define DEF_INSFILE "midimod.ins"
  21.  
  22. /* MOD sample to MIDI instrument map */
  23. #define DEF_MAPFILE "midimod.map"
  24.  
  25. /* Note conversion statements: */
  26. #define ANOTE(x) ((x < 0) ? (-x) : (NoteValue(x)))
  27. #define ENOTE(x,y) ((sam->m > 127) ? (sam->m - 128) : (ANOTE(x) + sam->t[y]))
  28. #define EVOL(x) ((x + sam->a[0]) * sam->a[1] / sam->a[2])
  29.  
  30. /* Amount of bytes of a sample read in when scanning it */
  31. #define SCANSIZE 3000
  32.  
  33. /* Make sure these fseek positions are defined (eg. on UNIX systems) */
  34. #ifndef SEEK_SET
  35. #define SEEK_SET 0
  36. #define SEEK_CUR 1
  37. #endif
  38.  
  39. /* Make sure this macro is defined */
  40. #ifndef min
  41. #define min(x,y) ((x > y) ? y : x)
  42. #endif
  43.  
  44. typedef char *string;
  45.  
  46. typedef struct bstruct {
  47.     FILE *f;                   /* File to read/write to */
  48.     unsigned char b[BUFFSIZE]; /* Holds buffer data */
  49.     unsigned int o, r;         /* Offset in buffer, Bytes actually read */
  50. } bfile[1];
  51.  
  52. struct bpos {
  53.     struct bstruct d; /* file data */
  54.     unsigned long p;  /* file position */
  55. };
  56.  
  57. typedef struct _X3 {
  58.     char n[23];         /* Sample name */
  59.     unsigned int l;     /* Number of ticks in length (4000 per second) */
  60.     unsigned char v, m; /* Volume of sample, Midi instrument */
  61.     signed char c;      /* Midi channel */
  62.     int t[3];           /* Transposition amounts */
  63.     int a[3];           /* Amplification formula: (Vol + a[0]) * a[1] / a[2] */
  64. } samp;
  65.  
  66. typedef struct _X4 {
  67.     unsigned char n; /* Number of samples */
  68.     samp s[31];      /* Sample information */
  69. } samps[1];
  70.  
  71.  
  72. /* Below are all of the dialog/info boxes */
  73.  
  74. string _IF[] = {
  75.   "Please enter the filename for the",
  76.     "",
  77.     "",
  78.     NULL
  79. };
  80.  
  81. string _CNVE[] = {
  82.     "Conversion Error:",
  83.     "",
  84.     "Both the MIDI and MOD files must be defined",
  85.     "before conversion can take place.",
  86.     NULL
  87. };
  88.  
  89. string _MODE[] = {
  90.     "Amiga Module Error:",
  91.     "",
  92.     "The MOD file you have chosen cannot be",
  93.     "understood by this program.",
  94.     NULL
  95. };
  96.  
  97. string _NOFIL[] = {
  98.     "File Error:",
  99.     "",
  100.     "Cannot locate the file",
  101.     "",
  102.     NULL
  103. };
  104.  
  105. string _MODM[] = {
  106.     "Amiga Module Error:",
  107.     "",
  108.     "There has been no MOD file defined yet, so",
  109.     "no samples have been loaded.",
  110.     NULL
  111. };
  112.  
  113. string _OOME[] = {
  114.     "Out Of Memory Error:",
  115.     "",
  116.     "For some reason, all of the available memory",
  117.     "has been allocated, and this program cannot",
  118.     "continue.",
  119.     NULL
  120. };
  121.  
  122. string _OUTE[] = {
  123.     "Warning:",
  124.     "",
  125.     "You have chosen a file which already exists.",
  126.     "Proceeding will overwrite this file. Press ",
  127.     "the letter 'Y' if this is ok.",
  128.     NULL
  129. };
  130.  
  131. string _TMC[] = {
  132.     "Instrument Error:",
  133.     "",
  134.     "You have selected too many different instruments.",
  135.     "There is a maximum of 16 different instruments, ",
  136.     "including 1 drum instrument. Please change your ",
  137.     "selection.",
  138.     NULL
  139. };
  140.  
  141. string _NOSAV[] = {
  142.     "File Access Error:",
  143.     "",
  144.     "The file " DEF_MAPFILE " cannot be replaced with",
  145.     "an updated version. Any changes to the instrument-maps",
  146.     "cannot be performed. Please exit from the program and",
  147.     "set up the necessary access permissions on this file if",
  148.     "you wish to use this command.",
  149.     NULL
  150. };
  151.  
  152. string _ABOUT[] = {
  153.     "MIDIMOD ver 0.2 (c) Andrew Scott (Adrenalin Software) '93",
  154.     "",
  155.     "MIDIMOD is a utility that aids in the conversion of .MOD",
  156.     "files (Amiga Sound/Noise/Protracker files) to MIDI files",
  157.     "(General MIDI format 1 files). Many effects are converted",
  158.     "but some cannot due to the differences between the two",
  159.     "formats. A log of instrument-maps can be kept and updated",
  160.     "to allow MIDIMOD to automatically allocate instruments,",
  161.     "transpositions, and volume shifts to known samples.",
  162.     "",
  163.     "Note: Some editting may be necessary after conversion due",
  164.     "to the lack of information stored in the .MOD file. Also,",
  165.     "MIDI players without tempo-track interpretting may not",
  166.     "play the converted MIDI file properly.",
  167.     NULL
  168. };
  169.  
  170. string _TRAQ[] = {
  171.     "Please enter a transposition value",
  172.     "for the sample you have just selected,",
  173.     "eg. '-12' for a bass guitar sample,",
  174.     "'0,3,7' for a minor chord, or '0,4,7'",
  175.     "for a major chord are usual.",
  176.     "",
  177.     NULL
  178. };
  179.  
  180. string _TRANE[] = {
  181.     "Transposition Error:",
  182.     "",
  183.     "You cannot set transposition values outside",
  184.     "the range -128 to 127. Much smaller values",
  185.     "are usual anyway. Your transposition is being",
  186.     "reset back to 0.",
  187.     NULL
  188. };
  189.  
  190. string _TRANWRN[] = {
  191.     "Transposition Warning:",
  192.     "",
  193.     "You have set transposition values for a percussion",
  194.     "instrument. This is not a good idea unless you know",
  195.     "what you are doing - effectively changing the",
  196.     "percussion instrument! The rest of the program can't",
  197.     "report correct information if you do this. Chords",
  198.     "are also not really possible for percussion. You",
  199.     "would be sensible to change the values to 0.",
  200.     NULL
  201. };
  202.  
  203. string _VSHQ[] = {
  204.     "Please enter the volume shift formula",
  205.     "values for the sample you have just",
  206.     "selected.",
  207.     "eg. For the formula (volume+12)*34/56",
  208.     "you would enter in '12,34,56'. In most",
  209.     "cases all you will need to enter are",
  210.     "the values '0,1,1'.",
  211.     "",
  212.     NULL
  213. };
  214.  
  215. string _VSHE[] = {
  216.     "Volume-shift Error:",
  217.     "",
  218.     "All three values for the formula must be entered",
  219.     "and cannot be outside the ranges -128 to 127,",
  220.     "0 to 127, and 1 to 127 respectively. Your values",
  221.     "do not meet these requirements and are being set",
  222.     "to the default: 0, 1, 1.",
  223.     NULL
  224. };
  225.  
  226. string _CNVPOS[] = {
  227.     "Please wait..",
  228.     "Currently converting",
  229.     "sample    ",
  230.     NULL
  231. };
  232.  
  233. string _DCQ[] = {
  234.     "Please enter the channel that any percussion",
  235.     "or drum instruments should be stored on.",
  236.     "(In general, 10 is a good choice)",
  237.     "",
  238.     NULL
  239. };
  240.  
  241. string _TTQ0[] = {
  242.     "Please choose the tempo-type. At the moment it",
  243.     "is set to type 0, which is the normal tempo",
  244.     "interpretting. Type 1 is the older tempo",
  245.     "interpretting. Press either 0 or 1.",
  246.     NULL
  247. };
  248.  
  249. string _TTQ1[] = {
  250.     "Please choose the tempo-type. At the moment it",
  251.     "is set to type 1, which is the older tempo",
  252.     "interpretting. Type 0 is the normal tempo",
  253.     "interpretting. Press either 0 or 1.",
  254.     NULL
  255. };
  256. 
  257.